package com.springcloud.eshop.message;

import java.util.Objects;

/**
 * @Desc: 数据变更消息
 * @Date: 2020-07-02
 * @Version:v1.0
 */
public class DataChangeMessage {

    /**
     * 操作类型
     */
    private String eventType;

    /**
     * 数据类型
     */
    private String dataType;

    /**
     * 主键
     */
    private long id;

    /**
     * 商品Id
     */
    private long productId;

    public DataChangeMessage() {
    }

    public DataChangeMessage(String eventType, String dataType, long id) {
        this(eventType, dataType, id, 0);
    }

    public DataChangeMessage(String eventType, String dataType, long id, long productId) {
        this.eventType = eventType;
        this.dataType = dataType;
        this.id = id;
        this.productId = productId;
    }

    public long getProductId() {
        return productId;
    }

    public void setProductId(long productId) {
        this.productId = productId;
    }

    public String getEventType() {
        return eventType;
    }

    public void setEventType(String eventType) {
        this.eventType = eventType;
    }

    public String getDataType() {
        return dataType;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        DataChangeMessage that = (DataChangeMessage) o;
        return id == that.id &&
                productId == that.productId &&
                Objects.equals(eventType, that.eventType) &&
                Objects.equals(dataType, that.dataType);
    }

    @Override
    public int hashCode() {
        return Objects.hash(eventType, dataType, id, productId);
    }
}
